package cn.com.nes.common.util;


/**
 * <p>
 * 常用公共方法
 * @author nes
 */
public class DBUtil {

    public static boolean isPicture(String pInput){
        String[] strs ={"bmp","png","jpg","jpeg","gif"};
        // 获得文件后缀名
        String tmpName = pInput.substring(pInput.lastIndexOf(".") + 1,
                pInput.length());
        for(int i=0; i<strs.length; i++){
            if(strs[i].equals(tmpName.toLowerCase())){
                return true;
            }
        }
        return false;
    }

    /**
     * 判断是否为语音
     * @param pInput
     * @return
     */
    public static boolean isVoice(String pInput){
        String[] strs ={"mp3","wma","m4a","flac","wav"};
        // 获得文件后缀名
        String tmpName = pInput.substring(pInput.lastIndexOf(".") + 1,
                pInput.length());
        for(int i=0; i<strs.length; i++){
            if(strs[i].equals(tmpName.toLowerCase())){
                return true;
            }
        }
        return false;
    }

    /**
     * 判断是否为视频
     * @param pInput
     * @return
     */
    public static boolean isVideo(String pInput){
        String[] strs ={"avi","wmv","mov","mp4","swf","flv","rm","ram"};
        // 获得文件后缀名
        String tmpName = pInput.substring(pInput.lastIndexOf(".") + 1,
                pInput.length());
        for(int i=0; i<strs.length; i++){
            if(strs[i].equals(tmpName.toLowerCase())){
                return true;
            }
        }
        return false;
    }
    /**
     * 判断是否为excel
     *
     * @param pInput
     * @return
     */
    public static boolean isFile(String pInput) {
        String[] strs = {"XLS","XLSX","XLSB","XLSM","CSV"};
        // 获得文件后缀名
        String tmpName = pInput.substring(pInput.lastIndexOf(".") + 1,
                pInput.length());
        for (int i = 0; i < strs.length; i++) {
            if (strs[i].equals(tmpName.toUpperCase())) {
                return true;
            }
        }
        return false;
    }
    
    public static String f_get_dwonQueryXzqh_report(String xzqhdm_fld,String xzqhjb) {
        int jb = Integer.parseInt(xzqhjb) ;
        StringBuffer sb = new StringBuffer() ;
        switch (jb) {
            case 0:
                sb.append(" concat(substr(").append(xzqhdm_fld).append(",1,2),'') ") ;
                break;
            case 1:
                //sb.append(" concat(substr(").append(xzqhdm_fld).append(",1,4),'00000000') ") ;

                sb.append(" if(concat(substr(").append(xzqhdm_fld).append(", 1, 4),'00000000')='110100000000',concat(substr(").append(xzqhdm_fld).append(", 1, 6),'000000'),concat(substr(").append(xzqhdm_fld).append(", 1, 4),'00000000')) ") ;


                break;
            case 2:
                sb.append(" concat(substr(").append(xzqhdm_fld).append(",1,6),'000000') ") ;
                break;
            case 3:
                sb.append(" concat(substr(").append(xzqhdm_fld).append(",1,9),'000') ") ;
                break;
            case 4:
                sb.append(" substr(").append(xzqhdm_fld).append(",1,12) ") ;
                break;
            default:
                sb.append(" ").append(xzqhdm_fld).append(" ") ;
                break;
        }
        return sb.toString() ;
    }

    public static void main(String[] args) throws Exception {

    }
}